package me.leiusual.sharing.ui.home.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.view_holder_home_search_store_child.*
import me.leiusual.sharing.api.model.storeproductquery.Product
import me.leiusual.sharing.util.extension.setImageUrl

/**
 * author: leiusual
 * create on: 2019-07-30
 * description:
 */
class HomeSearchStoreChildViewHolder(
    override val containerView: View,
    private val clickListener: (Product) -> Unit
) : RecyclerView.ViewHolder(containerView), LayoutContainer, View.OnClickListener {

  private lateinit var product: Product

  init {
    containerView.setOnClickListener(this)
  }

  fun bind(product: Product) {
    this.product = product

    image_view.setImageUrl(product.productImage)
  }

  override fun onClick(v: View?) {
    clickListener(product)
  }
}